///////////////////////////////////////
//    Autor: Mato Kormuth              //
//    (C) Mato Programs 2011        //
//////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Text;

namespace SimpleServerDB
{
    //Using the simple Mato Programs UserEvidence Server code.
    //(C) Mato Kormuth 2010

    /// <summary>
    /// Standart Comunticator
    /// </summary>
    public class ComunicatorV1
    {
        public void Login()
        {
            /*ALGORITMUS 
             * 1 vstup meno heslo>
             * 2 pripoj db(/db)
             * 3 over heslo(/db/meno/pass.txt)
             * 4 vrat c3 true alebo false
             * 5 metoda vrat bool "true" or "false
             */
        }

        public void Register()
        {
            /*ALGORITMUS
             * 1.1 over udaje
             * 1.2 pripoj db (/db)
             * 2 vytvor priecinok(/db/meno)
             * 3 uloz heslo (/db/meno/pass.txt)
             * 4 uloz email (/db/meno/email.txt)
             * 5 vrat serialkey
             * 6 vrat metodov "string" serialkey alebo chyba(0)
             */
        }

        public void ConnectDB()
        {

        }

        public void DisConnectDB()
        {

        }

        public string DownloadDBData(string user, DataType type)
        {
            //USES FILEDOWNLOAD.PHP - vrati text v html(webbrowser potrebny)
            //POTOM extrahujeme html kod do richtextbox
            //VRATIT string metoda "richtextbox.text"
            int a = 0;
            return a.ToString(); 
        }

        public void UploadDBData()
        {

        }

        public const string Version = "0.1.1.1";
        public const string Author = "Mato Kormuth";
    }

    /// <summary>
    /// DataBase Object - Class
    /// </summary>
    public class ComunicatorV2
    {
        string URL;
        string USER;
        string PASS;
        //string 
        public void Setup(string ServerURL, string ServerUSER, string ServerPASS)
        {
            URL = ServerURL;
            USER = ServerUSER;
            PASS = ServerPASS;
        }

        public string Return(DataType type)
        {
            //cesta /db/USER/
            int a = 0;
            return a.ToString(); 
        }
    }

    #region Comunicator Extra V3
    /// <summary>
    /// The third version of comunicator - extra functions(like sendmail and etc.)
    /// </summary>
    public class ComunicatorV3
    {
        bool Sucess = false;
        public void SendMail(string From, string To, string Subject, string Text, bool MsgBoxSucess)
        {
            System.Windows.Forms.WebBrowser wb = new System.Windows.Forms.WebBrowser();
            wb.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(wb_DocumentCompleted);
            Sucess = MsgBoxSucess;

            StringBuilder sb = new StringBuilder("http://www.dobrakmato.000space.com/ss/ssmail.php?to=" + To.ToString() + "&subject=" + Subject.ToString() + "&text=" + Text.ToString());
            wb.Navigate(sb.ToString());
        }

        void wb_DocumentCompleted(object sender, System.Windows.Forms.WebBrowserDocumentCompletedEventArgs e)
        {
            if (Sucess = true)
            {
                System.Windows.Forms.MessageBox.Show("SSMAIL: Sucess!");
            }
        }
    }
    #endregion

    /// <summary>
    /// Core of Mato Programs Code
    /// </summary>
    public class MatoProgramsCore
    {

    }

    /// <summary>
    /// Provides type of uploaded or downloaded data
    /// </summary>
    public enum DataType
    {
        Password,
        Email,
        Username,
        SerialKey,
        PlainText
    }
}
